// import Cookies from "js-cookie";

// const TokenKey = "vue_admin_template_token";

// export function getToken() {
//   return Cookies.get(TokenKey);
// }

// export function setToken(token) {
//   return Cookies.set(TokenKey, token);
// }

// export function removeToken() {
//   // return Cookies.remove(TokenKey)
//   localStorage.removeItem("adminToken");
// }
// import checkStatus from "@/api/checkStatus";
import router from "@/router/index";
export function getUser() {
  let obj = null;
  // checkStatus().then((res) => {
  //   if (res.code == 401) {
  //     window.localStorage.removeItem("users");
  //     router.replace({
  //       path: "/login",
  //       // query: { redirect: router.currentRoute.fullPath }
  //     });
  //     return null;
  //   }
  // });
  if (window.localStorage.getItem("users")) {
    if (window.localStorage.getItem("users")) {
      let user = JSON.parse(window.localStorage.getItem("users"));
      let obj = {
        userId: user.id,
        userName: user.name,
        userRole: user.role,
        userToken: user.token,
        avatar: user.avatar
      };
      // console.log(obj);
      return obj;
    }
  } else {
    window.localStorage.removeItem("users");
    router.replace({
      path: "/login",
    });
    return obj;
  }
}
